﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Diet
{
    public partial class GeneralForm : Form
    {
        public GeneralForm()
        {
            InitializeComponent();
        }

        
     
        private void button1_Click(object sender, EventArgs e)
        {
            int sum = 0;
            double[] diet = new double[3];

            try
            {
                this.Text = "Calculate complete";
                if ((Convert.ToInt32(KWeight.Text) + Convert.ToInt32(OWeight.Text)) > 1000)
                {
                    this.Text = "Неправильно введено количество ( < 1000 )";
                }
                else
                {
                    diet[0] = Convert.ToInt32(KKalor.Text);
                    diet[1] = Convert.ToInt32(KWeight.Text);

                    diet[2] = diet[0] * diet[1];
                    KSum.Text = Convert.ToString(diet[2]);

                    diet[0] = Convert.ToInt32(OKalor.Text);
                    diet[1] = Convert.ToInt32(OWeight.Text);

                    diet[2] = diet[0] * diet[1];
                    OSum.Text = Convert.ToString(diet[2]);

                    sum = sum + Convert.ToInt32(OSum.Text) + Convert.ToInt32(KSum.Text);
                    OKalorSum.Text = Convert.ToString(sum);
                }
            }
            catch
            {
                this.Text = "Неправильно введены данные";
            }
        }
    }
}
